package io;

import java.io.BufferedOutputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;

public class FlushDemo {
    public static void main(String[] args) throws IOException {
        FileOutputStream fos=new FileOutputStream("bos.txt");
        BufferedOutputStream bos=new BufferedOutputStream(fos);
        String line="为寂寞的夜空画上一个月亮，";
        bos.write(line.getBytes(StandardCharsets.UTF_8));
        System.out.println("写出完毕");
        bos.flush();//强制将缓冲流中缓冲在内部数组中的数据一次性写出
        bos.close();//会自动用flush
    }
}
